program sentinels;

{$R *.dres}

uses
  SysUtils,
  Gen2,
  smMain in '..\source\game\smMain.pas',
  Lua in '..\source\shared\Lua.pas',
  Data.DBXJSON in '..\source\shared\Data.DBXJSON.pas',
  smUtils in '..\source\shared\smUtils.pas',
  smConst in '..\source\shared\smConst.pas',
  smCommonTypes in '..\source\shared\smCommonTypes.pas',
  smExceptions in '..\source\shared\smExceptions.pas',
  smGUI in '..\source\game\gui\smGUI.pas',
  smGUIRender in '..\source\game\gui\smGUIRender.pas',
  smGUIPanel in '..\source\game\gui\smGUIPanel.pas',
  smGUIButton in '..\source\game\gui\smGUIButton.pas',
  smSceneManager in '..\source\game\scenes\smSceneManager.pas',
  smSceneRender in '..\source\game\scenes\smSceneRender.pas',
  smLuaUtils in '..\source\game\scripting\smLuaUtils.pas',
  smClassGame in '..\source\game\scripting\smClassGame.pas',
  smClassGUI in '..\source\game\scripting\smClassGUI.pas',
  smClassPlayer in '..\source\game\scripting\smClassPlayer.pas',
  smClassWorld in '..\source\game\scripting\smClassWorld.pas',
  smPlayer in '..\source\game\player\smPlayer.pas',
  smWorld in '..\source\game\world\smWorld.pas',
  smLocation in '..\source\game\world\smLocation.pas';

begin

  Game := TGameApplication.Create();
  try
    Game.Initialize();
  except
    G2WriteLogTimed('initialization exception');
  end;

  if Game.Tmr.Enabled then
  begin
    try
      Game.Loop();
    except
      G2WriteLogTimed('main loop exception');
    end;

    try
      Game.BeforeFinalize();
    except
      G2WriteLogTimed('finalization exception');
    end;
  end;

  if Assigned(Game) then
    try
      Game.Free();
    except
      G2WriteLogTimed('game.free exception');
    end;

end.
